package cn.ywsj.ywsjmidtier.utils;

import java.util.Collection;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CookiesUtil {
	public static String convertByMask(Collection collection,String mask){
		String rs="";
		Iterator iterator=collection.iterator();
		while(iterator.hasNext()){
			String sp=(String) iterator.next();
			rs+=sp+mask;
		}
		return rs;
	}
   public static String getCookieBySet(String name,String set){

       String regex=name+"=(.*?);";

       Pattern pattern = Pattern.compile(regex);
       Matcher matcher =pattern.matcher(set);
       if(matcher.find()){
           String matcherStr= matcher.group();
           int beginIndex=matcherStr.indexOf("=");
           return matcherStr.substring(beginIndex+1,matcherStr.lastIndexOf(";"));
       }
       return null;

   }
}
